1
|
|
|
/* |
2
|
|
|
* index.js |
3
|
|
|
* Copyright (c) 2017 [email protected] |
4
|
|
|
* |
5
|
|
|
* This file is part of Firefly III. |
6
|
|
|
* |
7
|
|
|
* Firefly III is free software: you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* Firefly III is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
/** global: searchQuery,searchUri */ |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
|
$(function () { |
26
|
|
|
"use strict"; |
27
|
|
|
startSearch(searchQuery); |
28
|
|
|
|
29
|
|
|
}); |
30
|
|
|
|
31
|
|
|
function startSearch(query) { |
32
|
|
|
$.post(searchUri, {query: query}).done(presentSearchResults).fail(searchFailure); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
function searchFailure() { |
36
|
|
|
$('.result_row').hide(); |
37
|
|
|
$('.error_row').show(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
function presentSearchResults(data) { |
41
|
|
|
$('.search_ongoing').hide(); |
42
|
|
|
$('p.search_count').show(); |
43
|
|
|
$('span.search_count').text(data.count); |
44
|
|
|
$('.search_box').find('.overlay').remove(); |
45
|
|
|
$('.search_results').html(data.html).show(); |
46
|
|
|
|
47
|
|
|
$('.select_all_single').unbind('change').change(function () { |
48
|
|
|
countChecked(); |
49
|
|
|
}); |
50
|
|
|
} |